//opencv_cuda.cpp:第二个程序主函数,使用自编静态库，实现cuda版本图片翻转
//authored by alpc40
//version：visual studio 2015\cuda toolkit 8.0\openCV 3.2.0
/*
#include <stdio.h>
#include<opencv2/opencv.hpp>
#include<iostream>
using namespace std;
using namespace cv;
#ifdef _DEBUG
#pragma comment ( lib,"opencv_core320d.lib")
#pragma comment ( lib,"opencv_highgui320d.lib")
#pragma comment ( lib,"opencv_calib3d320d.lib")
#pragma comment ( lib,"opencv_imgcodecs320d.lib")
#pragma comment ( lib,"opencv_imgproc320d.lib")
#pragma comment ( lib,"opencv_cudaimgproc320d.lib")
#pragma comment ( lib,"opencv_cudaarithm320d.lib")
#pragma comment ( lib,"cudart.lib")
#pragma comment ( lib,"swap_image.lib")//别忘了加库
#else
#pragma comment ( lib,"opencv_core320.lib")
#pragma comment ( lib,"opencv_highgui320.lib")
#pragma comment ( lib,"opencv_calib3d320.lib")
#pragma comment ( lib,"opencv_imgcodecs320.lib")
#pragma comment ( lib,"opencv_imgproc320.lib")
#pragma comment ( lib,"opencv_cudaimgproc320.lib")
#pragma comment ( lib,"opencv_cudaarithm320.lib")
#pragma comment ( lib,"cudart.lib")
#pragma comment ( lib,"swap_image.lib")//别忘了加库
#endif
//这个声明很重要,调用静态库
extern "C" void swap_image(cuda::GpuMat src, cuda::GpuMat dst, int w, int h);
int main(int argc, char** argv)
{
    Mat src, dst;
    cuda::GpuMat cu_src, cu_dst;
    int h, w;
    //根据argv[1]读入图片数据，BGR格式读进来
    src = imread(argv[1]);
    //检测是否正确读入
    if (src.data == NULL)
    {
        cout << "Read image error" << endl;
        return -1;
    }
    h = src.rows; w = src.cols;
    cout << "图片高：" << h << ",图片宽：" << w << endl;
    //上传CPU图像数据到GPU，跟cudaMalloc和cudaMemcpy很像哦，其实upload里面就是这么写的
    cu_src.upload(src);
    //申请GPU空间，也可以到函数里申请，不管怎样总要申请，要不然内核函数会爆掉哦
    cu_dst = cuda::GpuMat(h, w, CV_8UC3, Scalar(0, 0, 0));
    //申请CPU空间
    dst = Mat(h, w, CV_8UC3, Scalar(0, 0, 0));
    //调用函数swap_image,由该函数调用内核函数，这样层次分明，不容易出错
    //当然你也可以直接在这里调用内核函数，东西太多代码容易乱
    swap_image(cu_src, cu_dst, h, w);
    //下载GPU数据到CPU，与upload()对应
    cu_dst.download(dst);
    //显示cpu图像，如果安装了openCV集成了openGL,那可以直接显示GpuMat
    imshow("dst", dst);
    //等待按键
    waitKey();
    //写图片到文件
    if (argc == 3)
        imwrite(argv[2], dst);
    return 0;
}
*/